<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link rel="stylesheet" href="../lib/layui/css/layui.css" />
    <link rel="stylesheet" href="../css/reader/reader_cate.css" />
  </head>
  <body>
    <!-- 卡片区域 -->
    <div class="layui-card">
      <div class="layui-card-header">
        <span>新增读者</span>
        <button type="button" class="layui-btn layui-btn-radius layui-btn-sm" id="btnAddCate">添加读者</button>
      </div>
      <div class="layui-card-body">
        <table class="layui-table">
          <colgroup>
            <col />
            <col />         
            <col />
            <col />
            <col width="200" />
          </colgroup>
          <thead>
            <tr>
              <th>读者姓名</th>
              <th>电话号码</th>
              <th>读者性别</th>
              <th>读者职业</th>
              <th>操作</th>
            </tr>
          </thead>
          <tbody></tbody>
        </table>
      </div>
    </div>

    <!-- 表格数据的模板 -->
    <script type="text/html" id="tpl-table">
      {{each data}}
      <tr>
        <td>{{$value.readersName}}</td>
        <td>{{$value.readersPhone}}</td>
        <td>{{$value.readersSex}}</td>
        <td>{{$value.readersOccupation}}</td>
        <!-- $value 代表当前循环的那一行数据 -->
        <td>
          <button type="button" class="layui-btn layui-btn-radius layui-btn-warm layui-btn-xs btn-edit" data-id="{{$value.readersShowId}}">编辑</button>
          <button type="button" class="layui-btn layui-btn-radius layui-btn-danger layui-btn-xs btn-delete" data-id="{{$value.readersShowId}}">删除</button>
        </td>
      </tr>
      {{/each}}
    </script>

    <script type="text/html" id="tpl-table">
      <option value="">读者性别</option>
      {{each data}}
      <option value="{{$value.readersShowId}}" selected="">{{$value.readersSex}}</option>
      {{/each}}
    </script>

    <!-- 添加读者的弹出层 -->
    <script type="text/html" id="dialog-add">
      <form class="layui-form" id="form-add">
        <div class="layui-form-item">
          <label class="layui-form-label">读者姓名</label>
          <div class="layui-input-block">
            <input type="text" name="readersName" required  lay-verify="required" placeholder="请输入读者姓名" autocomplete="off" class="layui-input">
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">电话号码</label>
          <div class="layui-input-block">
            <input type="text" name="readersPhone" required  lay-verify="required" placeholder="请输入电话号码" autocomplete="off" class="layui-input">
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">读者性别</label>
          <div class="layui-input-block">
            <select name="readersSex" lay-filter="aihao">
              <option value="男">男</option>
              <option value="女">女</option>
            </select>
          </div>
        </div> 
        <div class="layui-form-item">
          <label class="layui-form-label">读者职业</label>
          <div class="layui-input-block">
            <input type="text" name="readersOccupation" required  lay-verify="required" placeholder="请输入读者职业" autocomplete="off" class="layui-input">
          </div>
        </div>
        <div class="layui-form-item">
          <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">确认添加</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
          </div>
        </div>
      </form>
    </script>

    <!-- 修改读者的弹出层 -->
    <script type="text/html" id="dialog-edit">
      <form class="layui-form" id="form-edit" lay-filter="form-edit">
        <!-- 隐藏域，保存 Id 的值 -->
        <input type="hidden" name="readersShowId">
        <div class="layui-form-item">
          <label class="layui-form-label">读者姓名</label>
          <div class="layui-input-block">
            <input type="text" name="readersName" required  lay-verify="required" placeholder="请输入读者姓名" autocomplete="off" class="layui-input">
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">电话号码</label>
          <div class="layui-input-block">
            <input type="text" name="readersPhone" required  lay-verify="required" placeholder="请输入电话号码" autocomplete="off" class="layui-input">
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">读者性别</label>
          <div class="layui-input-block">
            <select name="readersSex" lay-filter="aihao">
              <option value="男">男</option>
              <option value="女">女</option>
            </select>
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">读者职业</label>
          <div class="layui-input-block">
            <input type="text" name="readersOccupation" required  lay-verify="required" placeholder="请输入读者职业" autocomplete="off" class="layui-input">
          </div>
        </div>
        <div class="layui-form-item">
          <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">确认修改</button>
          </div>
        </div>
      </form>
    </script>

    <!-- 导入 layui 的js -->
    <script src="../lib/layui/layui.all.js"></script>
    <!-- 导入 jQuery -->
    <script src="../lib/jquery.js"></script>
    <!-- 导入 baseAPI -->
    <script src="../js/baseAPI.js"></script>
    <!-- 导入模板引擎 -->
    <script src="../lib/template-web.js"></script>
    <!-- 导入自己的 js -->
    <script src="../js/reader/reader_cate.js"></script>
  </body>
</html>
